package com.itheima.controller;

import com.itheima.service.OosService;
import com.itheima.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/aliyun/oss")
public class OosController {
    @Autowired
    private OosService oosService;
    @PostMapping("/upload")
    public ResponseEntity upload(MultipartFile photoFile) throws IOException {
       String url=oosService.upload(photoFile);
        //上传文件
        Map<String,String> map=new HashMap<>();
        map.put("url",url);
        return ResponseEntity.ok(Result.success(map));
    }
}
